//
//  MainViewController.m
//  happyHealthyWalk
//
//  Created by newhuidong on 16/2/19.
//  Copyright © 2016年 HuiDong. All rights reserved.
//

#import "MainViewController.h"
#import "Header.h"
#import "UIBarButtonItem+Extensions.h"
#import "SDCycleScrollView.h"
#import "HealthKnowViewController.h"
#import "ShareViewController.h"
#import "HealthWalkViewController.h"

@interface MainViewController ()<SDCycleScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *run_button;
@property (weak, nonatomic) IBOutlet UIButton *knowledge_button;
@property (weak, nonatomic) IBOutlet UIButton *help_button;
@property (weak, nonatomic) IBOutlet UIButton *share_button;
@property (weak, nonatomic) IBOutlet UIButton *wait_button;
@property (weak, nonatomic) IBOutlet UIButton *class_button;

@property(nonatomic,strong)UIScrollView * scroller;
@property(nonatomic,strong)NSArray * imageArr;

@end

@implementation MainViewController

-(void)viewDidLoad{
    
    [super viewDidLoad];
    
    self.view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    
    self.run_button.layer.cornerRadius=5;
    self.help_button.layer.cornerRadius=5;
    self.knowledge_button.layer.cornerRadius=4;
    self.wait_button.layer.cornerRadius=4;
    self.class_button.layer.cornerRadius=4;
    self.share_button.layer.cornerRadius=4;
    
    
    self.title=@"悦享健康行";
    [self setupNav];
    _imageArr=@[@"7.jpg",@"8.jpg",@"9.jpg"];
    
    [self setupScrollerView];
    
}

-(NSArray*)imageArr{
    
    if (_imageArr) {
        
        _imageArr=[NSArray arrayWithArray:_imageArr];
        
    }
    return _imageArr;
    
    
    
}

- (IBAction)walk:(id)sender {
    
    HealthKnowViewController * healthWalk=[[UIStoryboard storyboardWithName:@"HealthWalk" bundle:nil]instantiateViewControllerWithIdentifier:@"HealthWalkViewController"];
    
    
    [self.navigationController pushViewController:healthWalk animated:YES];
    
    
    
    
}

- (IBAction)knowledge:(id)sender {
    
    HealthKnowViewController * healthKnow=[[HealthKnowViewController alloc]init];
    
    [self.navigationController pushViewController:healthKnow animated:YES];
    
    

}
- (IBAction)share:(id)sender {
    NSLog(@"心得分享");
    
    ShareViewController * share=[[ShareViewController alloc]init];
    [self.navigationController pushViewController:share animated:YES];
    

}
- (IBAction)help:(id)sender {
    NSLog(@"健康援助");

}
- (IBAction)wait:(id)sender {
    NSLog(@"健康相伴");

}
- (IBAction)class:(id)sender {
    NSLog(@"健康讲座");

}

-(void)setupScrollerView{
    
    SDCycleScrollView* scrollView=[SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, ScreenW, 200) delegate:self placeholderImage:[UIImage imageNamed:@""]];
    
    scrollView.pageControlAliment=SDCycleScrollViewPageContolAlimentCenter;
    scrollView.currentPageDotColor=BlueColor;
    
    [self.view addSubview:scrollView];
    
    
    scrollView.imageURLStringsGroup=_imageArr;
    
    
}
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    
    NSLog(@"--点击了第%ld张图片",(long)index);
    
}
-(void)setupNav{
    
    self.navigationController.navigationBar.barTintColor=GreenColor;
    self.navigationController.navigationBar.translucent=NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage=[UIImage new];
    self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor whiteColor]};
    self.view.backgroundColor=[UIColor whiteColor];

    self.navigationItem.leftBarButtonItem=[UIBarButtonItem barButtonItemWithImage:@"data" hightLightImage:@"data" target:self action:@selector(onClickLeftItem)];
    
    
    
}
- (void)onClickLeftItem
{
    NSLog(@"111111");
    //发送通知，执行侧滑
    [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationLeftSlide object:nil];
}

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=NO;
    
    
    
    
    
}
-(void)viewWillDisappear:(BOOL)animated{
    self.help_button=nil;
    self.run_button=nil;
    self.wait_button=nil;
    self.share_button=nil;
    self.knowledge_button=nil;
    self.class_button=nil;
    
    
    
}
@end
